import {store} from "../store/store";

const setLoading = (loading) => {
    store.dispatch({ type: 'loading/setLoading', payload: loading})
}

const validatePhoneNumber = (value) => {
    return /^[1][3,4,5,7,8][0-9]{9}$/.test(value)
}

const validateStringLength = (value, min, max) => {
    if(value == null) return false
    return value.length >= min && value.length <= max
}


const CommonService = {
    setLoading,
    validatePhoneNumber,
    validateStringLength
}

export default CommonService